package com.chenhao.springcloud.chenhaodesignservice.pattern.creational.singleton;

import com.sun.deploy.util.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * Description:
 *
 * @author chenhao
 * @date 2020/12/21 10:23
 */
public class ContainerSingleton {
    private  static Map<String,Object> singletonMap = new HashMap <>();

    public static  void putInstance(String key,Object instance){
        if (key!=null&& instance !=null){
            if (!singletonMap.containsKey(key)){
                singletonMap.put(key,instance);
            }
        }

    }


    public static Object getInstance(String key){
        return singletonMap.get(key);
    }
}
